-- tsql
USE master
GO

CREATE SCHEMA sp_rename_dep_schema1
GO

CREATE TABLE sp_rename_dep_schema1.sp_rename_dep_dummy_table1(sp_rename_t1_col1 int, sp_rename_t1_col2 int);
GO

CREATE FUNCTION sp_rename_dep_dummy_func1() 
RETURNS INT
AS 
BEGIN
    RETURN 1;
END
GO

CREATE PROCEDURE sp_rename_dep_proc1
AS
BEGIN
    EXEC sp_rename 'sp_rename_dep_schema1.sp_rename_dep_dummy_table1', 'sp_rename_dep_dummy_table1_new', 'OBJECT';
    SELECT * FROM information_schema.tables WHERE TABLE_NAME LIKE '%sp_rename_dep%'
    ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME
END
GO

CREATE PROCEDURE sp_rename_dep_proc2
AS
BEGIN
    EXEC sp_rename 'sp_rename_dep_dummy_func1', 'sp_rename_dep_dummy_func1_new', 'OBJECT';
    SELECT ROUTINE_CATALOG, ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE 
    FROM information_schema.routines WHERE ROUTINE_NAME LIKE '%sp_rename_dep%' 
    ORDER BY ROUTINE_CATALOG, ROUTINE_SCHEMA, ROUTINE_NAME
END
GO

CREATE PROCEDURE sp_rename_dep_proc3
AS
BEGIN
    EXEC babelfish_sp_rename_internal 'sp_rename_dep_dummy_table1_new', 'sp_rename_dep_dummy_table1', 'sp_rename_dep_schema1', 'U';
    SELECT * FROM information_schema.tables WHERE TABLE_NAME LIKE '%sp_rename_dep%'
    ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME
END
GO